package com.ziyucoding.springboot.labs.lab3.sca.rocketmqdemo.consumerdemo.listener;

import com.ziyucoding.springboot.labs.lab3.sca.rocketmqdemo.consumerdemo.message.Demo1Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

/**
 * 示例1的消费者
 *
 * @author ziyucoding
 * @date 2022-10-24
 **/
@Component
public class Demo1Consumer {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @StreamListener(MySink.DEMO1_INPUT)
    public void onMessage(@Payload Demo1Message message) {
        logger.info("[onMessage][线程编号:{} 消息内容：{}]", Thread.currentThread().getId(), message);
        throw new RuntimeException("故意抛出异常，模拟消费失败");
    }
}
